﻿@using XXS.Common.Paginate;
@model IPaginate<KTD.Web.Models.VD.CustomerRecordVD>
<style>
    .saveResult .layui-form-label {
        width: 120px;
    }
</style>

<div class="x-body" id="box">
    <div class="layui-row">
        <form class="layui-form ">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    @Html.TextBox("Query", null, new { @class = "layui-input", placeholder = "关键字" })
                </div>
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </form>
    </div>

    <xblock style="height:50px;">

        <span class="x-right" style="line-height:40px">共有数据：@Model.SourceCount 条</span>
    </xblock>
    <button class="layui-btn layui-btn-danger" onclick="delAll('不通过')"><i class="layui-icon"></i>不通过</button>

    <button class="layui-btn layui-btn-normal" onclick="delAll('通过')"><i class="layui-icon"></i>通过</button>
    <table class="layui-table">
        <thead>
            <tr>
                <th>
                    <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                </th>
                <th style="width:200px;">客户</th>
                <th>报备楼盘</th>
                <th>带访经纪人</th>
                <th>到访时间</th>
                <th>状态</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.PageData)
            {
                <tr>
                    <td>
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='@item.Id'><i class="layui-icon">&#xe605;</i></div>
                    </td>
                    <td>@item.Customers</td>
                    <td>@item.HouseNames</td>
                    <td>@item.Brokers</td>
                    <td>@item.DateTime</td>
                    <td>@item.Status</td>
                </tr>
            }

        </tbody>
    </table>

    @{
        Html.RenderPartial("_paginate", Model);
    }



</div>


@section scripts{
    <script>




      function delAll (status) {

        var data = tableCheck.getData();
  
        layer.confirm('确认要'+status+'吗？'+data,function(index){
          
            $.ajax({
                     url: '/CustomerRecord/Update',
                        type: 'post',
                        data: {
                            Ids: data,
                            Status: status == "通过" ? 2 : 1
                        },
                        dataType: 'json',
                        success: function (res) {
                            if (res.success) {
                                layer.msg('已审核!', { icon: 1, time: 1000 });
                                window.location.reload();
                            }
                            else {
                                layer.msg('审核失败，' + res.msg, { icon: 2, time: 5000 });
                            }

                        }
               });
                
        });
      }

    </script>
}